#!/bin/bash
if [ -n "$1" ]  ; then
    I1="$1"
    if ! [ -n "$I1" -a -f "$I1" ] ;then
        cat <<EOF
USAGE:
$0 film1,avi [film1.txt [outputname (no .mp4 extension) [film2.avi [film2.txt]]]]
EOF
        exit 1 
    fi
    S1="$2"
    O="${3:-$(basename "$1" .avi)}".mp4
    I2="$4"
    S2="$5"
else
    I1=`zenity --file-selection --title="plik z filmem"`
    if [ "-z" "$I1" ] ; then
	exit 1
    fi
    S1=`zenity --file-selection --title="napis"`
    if [ "-n" "$S1" ] ; then
	D1=`zenity --entry --title="opoznienie napisu"`
    fi
    
    I2=`zenity --file-selection --title="drugi plik z filmem"`
    if [ "-n" "$I2" ] ; then
	if [ "-n" "$S1" ] ; then
	    S2=`zenity --file-selection --title="drugi napis"`
	    if [ "-n" "$S2" ] ; then
		D2=`zenity --entry --title="opoznienie napisu drugiego"`
	    fi
	fi
    fi
    O=`zenity --entry --title="plik wyjsciowy"`
    if [ "-z" "$O" ] ; then
	exit 1
    fi
    O=$O.mp4
fi
#echo "$I1:$S1:$I2:$S2:$O"
